<?php
include("includes/config.php");
$action = $_GET['action'];
if($action == ""){
	$sql = "SELECT DATE(activity) as date, COUNT(*) as count FROM bm_log GROUP BY DATE(activity) ORDER BY DATE(activity) DESC";
	$rs = mysql_query($sql);
	echo '<table width="100%" border="1">
	';
	while($row = mysql_fetch_array($rs)){
		if(count($row)>0){
			echo '<tr>
	';
				echo '<td><a href="?date='.$row['date'].'&action=view_date">'.$row['date'].'</td>
	';
				echo '<td>'.$row['count'].'</td>
	';
			echo '</tr>';
		}
	}
	echo '</table>';

	
}
elseif($action == "view_date"){
	
	$sql = "SELECT * FROM bm_log WHERE DATE(activity) = '".$_GET['date']."' ORDER BY activity DESC";
	$rs = mysql_query($sql);
	echo '<table width="100%" border="1">
	';

	while($row = mysql_fetch_array($rs)){
			echo '<tr>
	';
				echo '<td> '.$row['country_code'].' <br /> '.$row['ip'].'</td>
	';
				echo '<td>'.$row['activity'].'</td>
	';
				echo '<td>'.$row['url'].'&nbsp;</td>
	';
				echo '<td>'.$row['url_redirect'].'&nbsp;</td>
	';
			echo '</tr>';
	}
	echo '</table>';	
}
?>

